package com.chinadci.smartcommunitysystembackstage.mapper;

import com.chinadci.smartcommunitysystembackstage.entity.ScsActivity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chinadci.smartcommunitysystembackstage.entity.ScsAdmin;
import com.chinadci.smartcommunitysystembackstage.entity.ScsNotice;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
public interface ScsActivityMapper extends BaseMapper<ScsActivity> {
    //显示所有社区活动
    @Select("select * from scs_activity")
    @Results({
            @Result(id = true,column = "a_id",property = "aId"),
            @Result(column = "a_type",property = "aType"),
            @Result(column = "n_title",property = "aTitle"),
            @Result(column = "a_info",property = "aInfo"),
            @Result(column = "a_count",property = "aCount"),
            @Result(column = "a_create_time",property = "aCreateTime"),
            @Result(column = "a_start_time",property = "aStartTime"),
            @Result(column = "a_end_time",property = "aEndTime"),
            @Result(column = "admin_id",property = "admin",many =@Many(select = "Select"))
    })
    List<ScsActivity> Find();

    @Select("select * from scs_admin where a_id=#{a_id}")
    List<ScsAdmin> Select(int id);



    @Select("select * from scs_activity where a_type=#{type}")
    @Results({
            @Result(id = true,column = "a_id",property = "aId"),
            @Result(column = "a_type",property = "aType"),
            @Result(column = "n_title",property = "aTitle"),
            @Result(column = "a_info",property = "aInfo"),
            @Result(column = "a_count",property = "aCount"),
            @Result(column = "a_create_time",property = "aCreateTime"),
            @Result(column = "a_start_time",property = "aStartTime"),
            @Result(column = "a_end_time",property = "aEndTime"),
            @Result(column = "admin_id",property = "admin",many =@Many(select = "Select"))
    })
    List<ScsActivity> Finds(String type);

    @Select("select * from scs_activity where a_id=#{id}")
    @Results({
            @Result(id = true,column = "a_id",property = "aId"),
            @Result(column = "a_type",property = "aType"),
            @Result(column = "n_title",property = "aTitle"),
            @Result(column = "a_info",property = "aInfo"),
            @Result(column = "a_count",property = "aCount"),
            @Result(column = "a_create_time",property = "aCreateTime"),
            @Result(column = "a_start_time",property = "aStartTime"),
            @Result(column = "a_end_time",property = "aEndTime"),
            @Result(column = "admin_id",property = "admin",many =@Many(select = "Select"))
    })
    List<ScsActivity> Findinsert(int id);
}
